package com.haian.slidealbum.control;

import java.util.ArrayList;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.Window;

import com.haian.slidealbum.R;
import com.haian.slidealbum.common.ConstCommon;
import com.haian.slidealbum.model.adapter.AdapterFullScreenImage;
import com.haian.slidealbum.model.object.ObjectImage;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;

public class ImageViewDetailActivity  extends Activity{

	ViewPager viewPager;
	int position_click;
	ArrayList<ObjectImage> array_image;
	ImageLoader imageLoader;
	DisplayImageOptions options;
	Context mcontext;
	AdapterFullScreenImage adapterFullScreen;
	float x = 0, y = 0, oldX = 0, oldY = 0;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    requestWindowFeature(Window.FEATURE_NO_TITLE);
	    setContentView(R.layout.activity_photo_detail);
	    overridePendingTransition(R.drawable.activity_transaction_trans_left_in, R.drawable.activity_transaction_trans_left_out);
	    initDB();
	    initWidget();
	}
	
	@Override
	public void onBackPressed() {
	    super.onBackPressed();
	    overridePendingTransition(R.drawable.activity_transaction_trans_right_in, R.drawable.activity_transaction_trans_right_out);
	}
	
	@SuppressWarnings("unchecked")
	private void initDB() {
		mcontext = this;
		Intent intent = new Intent();
		intent = getIntent();
		position_click = intent.getExtras().getInt(ConstCommon.KEY_POSITION);
		array_image = new ArrayList<ObjectImage>();
		array_image = (ArrayList<ObjectImage>) intent.getExtras().getSerializable(ConstCommon.KEY_ARRAY_IMAGE);
	}
	
	private void initWidget() {
		viewPager = (ViewPager) findViewById(R.id.pager);
		adapterFullScreen = new AdapterFullScreenImage(this, array_image);
		viewPager.setAdapter(adapterFullScreen);
		viewPager.setCurrentItem(position_click);
	}
}
